<template>
	<view class="page">
		<view class="feedback-container">
			<!-- 页面头部图标 -->
			<view class="feedback-header">
				<image src="/static/svg/feedback-banner.svg" mode="widthFix" class="feedback-banner"></image>
			</view>
			
			<!-- 反馈表单 -->
			<view class="feedback-form">
				<!-- 标题已在SVG banner中展示 -->
				
				<!-- 反馈类型选择 -->
				<view class="form-item">
					<view class="form-label">反馈类型 <text class="required">*</text></view>
					<view class="radio-group">
						<view class="radio-item" :class="{ 'radio-active': feedbackType === 'bug' }" @click="selectType('bug')">
							<view class="radio-circle" :class="{ 'radio-checked': feedbackType === 'bug' }"></view>
							<text class="radio-text">系统bug</text>
						</view>
						<view class="radio-item" :class="{ 'radio-active': feedbackType === 'suggestion' }" @click="selectType('suggestion')">
							<view class="radio-circle" :class="{ 'radio-checked': feedbackType === 'suggestion' }"></view>
							<text class="radio-text">使用建议</text>
						</view>
						<view class="radio-item" :class="{ 'radio-active': feedbackType === 'spit' }" @click="selectType('spit')">
							<view class="radio-circle" :class="{ 'radio-checked': feedbackType === 'spit' }"></view>
							<text class="radio-text">吐槽</text>
						</view>
						<view class="radio-item" :class="{ 'radio-active': feedbackType === 'report' }" @click="selectType('report')">
							<view class="radio-circle" :class="{ 'radio-checked': feedbackType === 'report' }"></view>
							<text class="radio-text">不良信息举报</text>
						</view>
					</view>
				</view>
				
				<!-- 详细描述 -->
				<view class="form-item">
					<view class="form-label">详细描述 <text class="required">*</text></view>
					<view class="textarea-container">
						<textarea class="feedback-textarea" v-model="feedbackContent" placeholder="请详细描述您遇到的问题或建议..." maxlength="500"></textarea>
						<view class="textarea-counter">{{feedbackContent.length}}/500</view>
					</view>
				</view>
				
				<!-- 邮箱 -->
				<view class="form-item">
					<view class="form-label">邮箱 <text class="required">*</text></view>
					<view class="input-container">
						<input type="text" class="feedback-input" v-model="email" placeholder="请留下您的邮箱，以便我们回复您" />
					</view>
				</view>
				
				<!-- 提交按钮 -->
				<view class="form-item submit-container">
					<button class="submit-button" @click="submitFeedback" :disabled="!canSubmit">提交反馈</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref, computed } from 'vue';

// 表单数据
const feedbackType = ref('');
const feedbackContent = ref('');
const email = ref('');

// 选择反馈类型
const selectType = (type) => {
	feedbackType.value = type;
}

// 判断是否可以提交
const canSubmit = computed(() => {
	return feedbackType.value !== '' && 
	       feedbackContent.value.trim() !== '' && 
	       /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(email.value);
});

// 提交反馈
const submitFeedback = () => {
	if (!canSubmit.value) {
		uni.showToast({
			title: '请完成所有必填项',
			icon: 'none'
		});
		return;
	}
	
	// 提交数据到服务器
	uni.showLoading({
		title: '提交中...'
	});
	
	// 模拟提交
	setTimeout(() => {
		uni.hideLoading();
		uni.showToast({
			title: '反馈提交成功',
			icon: 'success',
			duration: 2000,
			success: () => {
				// 延迟返回
				setTimeout(() => {
					uni.navigateBack();
				}, 2000);
			}
		});
	}, 1500);
}
</script>

<style>
.page {
	background-color: #f5f5f5;
	min-height: 100vh;
}

.feedback-container {
	padding: 30rpx;
}

.feedback-header {
	display: flex;
	justify-content: center;
	margin-bottom: 20rpx;
}

.feedback-banner {
	width: 100%;
}

.feedback-form {
	background-color: #FFFFFF;
	border-radius: 12rpx;
	padding: 30rpx;
	box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}

/* 标题已在SVG banner中展示 */

.form-item {
	margin-bottom: 30rpx;
}

.form-label {
	font-size: 28rpx;
	color: #333;
	margin-bottom: 20rpx;
}

.required {
	color: #FF0000;
}

.radio-group {
	display: flex;
	flex-direction: column;
}

.radio-item {
	display: flex;
	align-items: center;
	padding: 20rpx 0;
	border-bottom: 1rpx solid #f0f0f0;
}

.radio-circle {
	width: 36rpx;
	height: 36rpx;
	border-radius: 50%;
	border: 2rpx solid #ddd;
	margin-right: 20rpx;
	display: flex;
	justify-content: center;
	align-items: center;
}

.radio-checked {
	border: 2rpx solid #FF6E31;
}

.radio-checked::after {
	content: '';
	width: 20rpx;
	height: 20rpx;
	border-radius: 50%;
	background-color: #FF6E31;
}

.radio-text {
	font-size: 28rpx;
	color: #333;
}

.radio-active {
	background-color: #FFF9F3;
}

.textarea-container {
	position: relative;
	border: 1rpx solid #e5e5e5;
	border-radius: 8rpx;
	padding: 20rpx;
	background-color: #FAFAFA;
}

.feedback-textarea {
	width: 100%;
	height: 300rpx;
	font-size: 28rpx;
	line-height: 1.5;
}

.textarea-counter {
	position: absolute;
	right: 20rpx;
	bottom: 10rpx;
	font-size: 24rpx;
	color: #999;
}

.input-container {
	border: 1rpx solid #e5e5e5;
	border-radius: 8rpx;
	padding: 20rpx;
	background-color: #FAFAFA;
}

.feedback-input {
	width: 100%;
	height: 80rpx;
	font-size: 28rpx;
}

.submit-container {
	margin-top: 60rpx;
}

.submit-button {
	width: 100%;
	height: 90rpx;
	background-color: #FF6E31;
	color: #fff;
	border-radius: 45rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 32rpx;
	font-weight: bold;
}

.submit-button[disabled] {
	background-color: #FFB18A;
	color: #fff;
}
</style>
